﻿using AdverseEventReportSystem.BLL.ServiceReference1;
using AdverseEventReportSystem.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace AdverseEventReportSystem.Web.Areas.Personnel
{
    public class PersonnelListController : BaseController
    {
        // GET: Personnel/PersonnelList
        public ActionResult Index()
        {
            return View();
        }

        /// <summary>
        /// 档案列表
        /// </summary>
        /// <returns></returns>
        public ActionResult Search()
        {
            int pageIndex = DataConvert.StrToInt(Request["page"], 1);
            int pageSize = DataConvert.StrToInt(Request["pageSize"], ConfigHelper.GetConfigInt("pagesize"));
            int inServiceStatus = DataConvert.StrToInt(Request["inServiceStatus"]);
            string name = DataConvert.ToString(Request["name"]);
            string areaId = DataConvert.ToString(Request["areaId"]);
            string departmentCode = "";
            if (areaId == "-1")
            {
                departmentCode = loginUser.DepartCode;
            }
            else
            {
                departmentCode = areaId;
            }

            FunctionAndPermissionsSoapClient service = new FunctionAndPermissionsSoapClient();
            ResultHelperOfArchivesListData serviceResult = service.getP_Personnel(-1, name, pageIndex, pageSize, departmentCode, inServiceStatus);
            ArchivesListData data = new ArchivesListData();
            if (serviceResult.S)
            {
                data = serviceResult.D;
            }

            var result = new { Total = data.RowNum, Rows = data.ArchivesList };
            return JsonDate(result);
        }
    }
}